import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: 'home',
    //路由重定向 直接访问home页面
    component: () => import('../views/main.vue'),
    children: [
      { path: 'user', name: 'user', component: () => import('../views/user.vue') },
      { path: 'home', name: 'home', component: () => import('../views/home.vue') },
      { path: 'mall', name: 'mall', component: () => import('../views/mall.vue') },
      { path: 'page1', name: 'page1', component: () => import('../views/pageone.vue') },
      { path: 'page2', name: 'page2', component: () => import('../views/pagetwo.vue') },
    ]
  },
  {
    path: '/login',
    name:'login',
    component: () => import('../views/login.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
